<?php
namespace Common\Models;
use Common\BaseModel;
class Ad extends BaseModel
{
    public $res;
    public $expire;
    public function getSource()
    {
        return "view_home_ad";
    }
    public function initialize()
    {
        parent::initialize();
        $this->res['res']=false;
        $this->expire=60*60*20;
        /*
                    $this->res['code']=000;
                    $this->res['msg']='msg';
                    return $this->res;
         empty() intval()
         */
    }
    public function FindByid($id){
        //$condition['conditions']="is_defalut =1";
        //	$condition['columns']='id';
        $res=$this->findFirst($id);
        if(empty($res)){
            return false;
        }else{
            return	$res;
        }
    }
    //拿广告
    public function getListByIds($ids,$user_info=[]){
        $data=[];
        $ids=explode(",",$ids);

        $material= new Material();
        foreach($ids as $k => $v){
            $one=$this->FindByid($v)->toArray();
            $carousel_one=$material->getListByIds($one['ids'],$user_info);
            unset($one['ids']);
            $one['list']=$carousel_one;
            $data[]=$one;
        }
        return $data;
    }

}
